package com.api.devices.domain.vo;

import com.alibaba.fastjson2.JSONObject;
import com.api.common.core.domain.BaseEntity;
import com.api.common.utils.StringUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Date;
import java.util.List;
import java.util.Set;

@Getter
@Setter
public class MonitoredVo extends BaseEntity {
    private String monitoredCode;
    private Long groupId;
    private List<Long> groupIdList;
    private String ipcCode;
    private String[] ipcCodeList;
    private String monitoredName;
    private String strMonitoredNameLocales;
    private JSONObject monitoredNameLocales;
    private Set<String> datColSet;
    private String strDatColSet;
    /**
     * 描述
     */
    private String remark;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 创建人
     */
    private String createBy;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;
    /**
     * 更新人
     */
    private String updateBy;
    /**
     * 选择第N页
     */
    private int pageNum;
    /**
     * 每页显示量
     */
    private int pageSize;

    private String appLang;

    public void setMonitoredNameLocales(JSONObject monitoredNameLocales) {
        this.monitoredNameLocales = monitoredNameLocales;
        if(ObjectUtils.isNotEmpty(monitoredNameLocales))
            this.strMonitoredNameLocales = monitoredNameLocales.toString();
    }

    public void setDatColSet(Set<String> datColSet) {
        this.datColSet = datColSet;
        if(ObjectUtils.isNotEmpty(datColSet))
            this.strDatColSet = datColSet.toString();
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }


    public void setIpcCode(String ipcCode) {
        this.ipcCode = ipcCode;
        if(ipcCode.contains(",")){
            this.ipcCodeList = ipcCode.split(",");
        } else if(StringUtils.isNotEmpty(ipcCode)){
            this.ipcCodeList = new String[]{ipcCode};
        }
    }
}
